package com.tm.springboot1.controller;

import com.tm.springboot1.pojo.Student;
import com.tm.springboot1.service.StudentService;
import com.tm.springboot1.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: springboot1
 * @description: java
 * @author: 小仝
 * @create: 2023-04-10 19:30
 **/

@RestController
public class StudentController {

    @Autowired
    private StudentService studentService;

    /**
     *  用Aid查询数据
     */
    @GetMapping("getById/{AId}")
    public Result getById(@PathVariable Integer AId){
        return studentService.findAll(AId);
    }

    /**
     *  添加数据
     */
    @PostMapping("insert")
    public Result insert(@RequestBody Student student){
        return studentService.insert(student);
    }

    /**
     *  修改数据
     */
    @PutMapping("update")
    public Result update(@RequestBody Student student){
        return studentService.update(student);
    }

    /**
     *  删除数据
     */
    @DeleteMapping("delete/{Aid}")
    public Result delete(@PathVariable Integer Aid){
        return studentService.delete(Aid);
    }

}